<?php
// 从所有商品从数据库里取出来响应给前端
$con = mysqli_connect('localhost', 'root', 'root');

// 2、选择要操作的数据库
mysqli_select_db($con, '2004');

// 3、设置编码
mysqli_query($con, "set charset 'utf8'");
mysqli_query($con, "set character set 'utf8'");

$sql = "select * from shop";

$res = mysqli_query($con, $sql);
$list = array();
while($row = mysqli_fetch_assoc($res)) {
    array_push($list, $row);
};

echo json_encode(array(
    "code" => 200,
    "list" => array(
        "list" => $list
    )
    ));

?>